<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>监理通知---监理通知回执单</title>

    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--extended-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--公用样式JS-->
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/jquery.boot.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
    <script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
</head>
<style type="text/css">
    .main {
        float: left;
        margin-left: 8px;
    }
    .downModule button{
        width: 90px;
        height: 34px;
        border: 0;
        margin: 10.5px 0 0 10px;
        border-radius: 3px;
        border: 1px solid #EEEEEE;
    }
</style>

<body>
<!--容器-->
<div>
    <div class="downModule whitebg">
        <ul class="mt30 mb30">
            <li>
                <div class="clearfix">
                    <div class="downModuleTip clearfix fl">
                        <img src="${re.contextPath}/plugin/common/images/15@2x.png" alt="" class="fl">
                        <span class="fl ml10 mt10 milefile" data-filetype="111">监理通知回执单</span>
                        <input type="hidden" name="id" id="id" value="${filedto.projectId}">
                        <input type="hidden" name="spmId" id="spmId" value="${filedto.spmId}">
                        <input type="hidden" name="fbCode" id="fbCode" value="${contract.code}">
                        <input type="hidden" name="fileId" id="fileId" value="${filedto.id}">
                        <input type="hidden" name="stageId" id="stageId" value="${filedto.stageId}">
                        <input type="hidden" name="fbId" id="fbId" value="${contract.id}">
                    </div>
                    <div class="downModuleBtn clearfix fr">
                        <label>
                            <img style="display: none;" src="${re.contextPath}/plugin/common/images/18@2x.png" alt=""
                                 class="fl ">
                            <button type="button" style="display: none;" lay-data="{type: '111',value:'11'}"
                                    class="img-upload whitebutton ft12 blue">点击上传
                            </button>
                        </label>
                        <img src="${re.contextPath}/plugin/common/images/57@2x.png" alt="" class="fl"
                             onclick="addForm(this)">
                        <img src="${re.contextPath}/plugin/common/images/19@2x.png" alt="" class="fl"
                             onclick="clickDelete(this)">
                    </div>
                </div>
                <ul class="clearfix" id="hzd">
                    <#list list_file as vo>
                        <li class="clearfix">
                            <input type="checkbox" class="fl" value="${vo.id}" title="jlzb">
                            <span class="fl ml10">${vo.fileName}</span>
                            <@shiro.hasPermission name="file:uthrstamp">
                                <button type="button" class="fr ml20 mt15 bgnone btn_cfsq" onclick="cfsqclick(this)">
                                    承发三签
                                </button>
                            </@shiro.hasPermission>
                            <@shiro.hasPermission name="file:export">
                                <button type="button" class="fr ml20 mt15 bgnone"
                                        onclick="_prom_page.events.exportFile(this)">导出
                                </button>
                            </@shiro.hasPermission>
                            <@shiro.hasPermission name="file:view">
                                <button type="button" class="fr mt15 bgnone ml20 btn_vew" onclick="_prom_page.events.viewclick(this)">查看</button>
                            </@shiro.hasPermission>
                            <@shiro.hasPermission name="file:upseal">
                                <button type="button" class="fr mt15 bgnone ml20 upseal tabsealup0">上传签章</button>
                            </@shiro.hasPermission>

                        </li>
                    </#list>
                </ul>
            </li>
        </ul>

        <div class="popUpBtn center">
            <button type="button" class="blue bgnone close">关闭</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="${re.contextPath}/plugin/system/supervisor/projectManager.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/system/supervisor/guide.js"></script>
<script>
    var layer, form, laydate, upload, uploadListIns, element, tableIns, table;
    $(function () {
        layui.use(['form', 'laydate', 'layer', 'upload', 'element', 'table'], function () {
            laydate = layui.laydate;
            form = layui.form;
            upload = layui.upload;
            element = layui.element;
            table = layui.table;
        });
    });

    $('.close').click(function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    });


    function addForm(object) {
        var  lilength=$("#hzd").find("li").length;
        if(lilength>0){
            layer.msg("已经存在回执单", {icon: 2});
            return false;
        }
        var id = $("#id").val();// 项目id
        var spmId = $("#spmId").val();// spmId
        var stageId = $("#stageId").val();// stageId
        var fileId = $("#fileId").val();// 文件id
        var fbId = $("#fbId").val();
        var type = "111";// 文件类型
        var fbCode = $("#fbCode").val();//分包编号
        var title = "";
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width() - 200);
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 200);
        }
        // 获取

        var url = "/supervisor/projectManager/addForm?type=" + type + "&id=" + id + "&stageId=" + stageId + "&spmId=" + spmId + "&fbCode=" + fbCode + "&fileId=" + fileId + "&fbId=" + fbId;
        layer.open({
            id: 'form-add',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: title,
            content: url,
            end: function () {
                reload();//刷新列表页面
            }
        });

    }

    function clickDelete(object) {
        var checkbox = $(object).parent().parent().next().find("input:checked");
        if (checkbox.length == 0) {
            layer.msg("请选择文件", {icon: 2});
            return;
        }
        var ids = [];
        checkbox.each(function (i, v) {
            var _a = $(v).attr("value");
            ids.push(_a);
        });
        var ids = ids.join(',');
        layerAjax("deleteFile",{"ids": ids},'',function (d) {
            if(d.flag){
                checkbox.each(function (i, v) {
                    $(v).parent().remove();
                });
                layer.msg("删除成功！");
            }else{
                layer.msg(d.msg, {icon: 2});
            }
        })

    }

    // 承发三签
    function cfsqclick(object) {
        // 承发三签
        var that = $(object);
        // 文件id
        var fileId = that.parent().find('input[type=checkbox]').attr('value');
        // 项目id
        var projectId = "${filedto.projectId}";
        var spanfile = that.parent().find("span").html()
        var fileName = spanfile.substring(0, spanfile.indexOf('.'));
        var fbId = $("#fbId").val();
        var jsonsp = {
            type: "005",//承发三签
            projectId: projectId,
            fileId: fileId,
            fileName: fileName,
            fbId: fbId
        }
        layer.confirm('提示：多个承建单位签字需线下走完流程，上传签章图片。如果没有上传监理项目用章授权书，请上传后再发起流程。确定发起承发三签吗？', function (index) {
            layerAjax('/supervisor/lcManager/updateStartLc', jsonsp, '', function (d) {
                if (d.flag == true) {
                    layer.msg(d.msg);
                } else {
                    layer.msg(d.msg, {icon: 2});
                }
                console.log(d);
            });

        });



    }

    // form 关闭之后回调
    function reload() {
        window.location.reload()
    }
</script>
</body>

</html>